home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / PowerD_mui / lib / startup_mui.ass next >
Encoding:
Text File  |  2002-03-13  |  2.8 KB  |  102 lines

  1. START    movem.l    d0/a0,-(a7)    ;save initial values
  2.     movea.l    $4.w,a6
  3.     suba.l    a1,a1
  4.     jsr    (-294,a6)        ; FindTask()
  5.     move.l    d0,a4
  6.     tst.l    (172,a4)        ; process.cli
  7.     beq.s    workbench
  8.     movem.l    (a7)+,d0/a0    ;restore regs
  9.     bra.s    cli        ;and run the user prog
  10. workbench    lea    (92,a4),a0    ; process.msgport
  11.     jsr    (-384,a6)        ;wait for a message (WaitPort(())
  12.     lea    (92,a4),a0    ; process.msgport
  13.     jsr    (-372,a6)        ;then get it (GetMsg())
  14.     move.l    d0,_wbmessage        ;save it for later reply
  15.     movem.l    (a7)+,d0/a0    ;restore
  16. cli    bsr.s    _START        ;call our program
  17.     move.l    d0,-(a7)        ;save it
  18.     tst.l    _wbmessage
  19.     beq.s    exittodos        ;if I was a CLI
  20.     jsr    (-132,a6)        ; Forbid()
  21.     move.l    (_wbmessage,pc),a1
  22.     jsr    (-138,a6)        ; Permit()
  23. exittodos    move.l    (a7)+,d0        ;exit code
  24.     rts
  25.  
  26. _START  move.l  a0,_arg
  27.         clr.b   (-1,a0,d0.w)
  28.         movea.l $4.w,a6
  29.         lea     (DOSName,pc),a1
  30.         moveq   #37,d0
  31.         jsr     (-552,a6)               ; OpenLibrary()
  32.         move.l  d0,_DOSBase
  33.         beq.s   .FINISH
  34.  
  35.         movea.l d0,a6
  36.         jsr     (-60,a6)                ; Output()
  37.         move.l  d0,_stdout
  38.         jsr     (-54,a6)                ; Input()
  39.         move.l  d0,_stdin
  40.  
  41.         movea.l $4.w,a6
  42.         lea     (IntName,pc),a1
  43.         moveq   #37,d0
  44.         jsr     (-552,a6)               ; OpenLibrary()
  45.         move.l  d0,_IntuitionBase
  46.         beq.s   .CLOSEDOS
  47.  
  48.         movea.l $4.w,a6
  49.         lea     (GfxName,pc),a1
  50.         moveq   #37,d0
  51.         jsr     (-552,a6)               ; OpenLibrary()
  52.         move.l  d0,_GfxBase
  53.         beq.s   .CLOSEINT
  54.  
  55.         movea.l $4.w,a6
  56.         lea     (MUIName,pc),a1
  57.         moveq   #19,d0
  58.         jsr     (-552,a6)
  59.         move.l  d0,_MUIMasterBase
  60.         beq.s   .CLOSEGFX
  61.  
  62.         xref    _main
  63.         jsr     _main           ; a6 is stored
  64.         move.l  d0,d2
  65.  
  66.         movea.l _MUIMasterBase,a1
  67.         jsr     (-414,a6)               ; CloseLibrary()
  68. .CLOSEGFX
  69.         movea.l _GfxBase,a1
  70.         jsr     (-414,a6)               ; CloseLibrary()
  71. .CLOSEINT
  72.         movea.l _IntuitionBase,a1
  73.         jsr     (-414,a6)               ; CloseLibrary()
  74. .CLOSEDOS
  75.         movea.l _DOSBase,a1
  76.         jsr     (-414,a6)               ; CloseLibrary()
  77. .FINISH move.l  d2,d0
  78.         rts
  79. ****************************************
  80.         xdef    _DOSBase
  81.         xdef    _IntuitionBase
  82.         xdef    _GfxBase
  83.         xdef    _MUIMasterBase
  84.         xdef    _arg
  85.         xdef    _stdout
  86.         xdef    _stdin
  87.         xdef    _wbmessage
  88. ****************************************
  89. _DOSBase        dc.l    0
  90. _IntuitionBase  dc.l    0
  91. _GfxBase        dc.l    0
  92. _MUIMasterBase  dc.l    0
  93. _arg            dc.l    0
  94. _stdout         dc.l    0
  95. _stdin          dc.l    0
  96. _wbmessage      dc.l    0
  97. ****************************************
  98. DOSName dc.b    'dos.library',0
  99. IntName dc.b    'intuition.library',0
  100. GfxName dc.b    'graphics.library',0
  101. MUIName dc.b    'muimaster.library',0
  102.